import { NoSkinCellRenderer } from "../../common/item/NoSkinCellRenderer";
import { ObjCreate } from "../../common/ObjCreate";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { ResouceConst } from "../../../../component/gconst/ResouceConst";
import { BossFieldOrderData } from "../cellData/BossFieldOrderData";
import { ColorConfig } from "../../../resource/ColorConfig";
import { GameConst } from "../../../../component/gconst/GameConst";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { GameDefConfig } from "../../../resource/GameDefConfig";
import { Language } from "../../../../../extend/language/Language";
import { Alert } from "../../../../../com/mui/controls/Alert";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { RoleAvatar } from "../../avatar/RoleAvatar";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
import { GButton } from "../../../../../com/mui/controls/GButton";
import { SBossFieldInfo } from "../../../../../Message/Public/SBossFieldInfo";
type int = number;
//class CrossBossFieldStateCellRenderer
    
    export  class CrossBossFieldStateCellRenderer extends NoSkinCellRenderer
    {
        constructor()
        {
            super();
            this.mouseChildren = true;
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            this._commonEnterBtn = ObjCreate.createGButton("", 238, 5, 70, 22, this);
            this._commonEnterBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onCommonEnterHandler);
            this._bossEnterBtn = ObjCreate.createGButton("", 238, 32, 70, 22, this);
            this._bossEnterBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onBossEnterHandler);
            this._commonEnterBtnLabel = ObjCreate.createGTextField("", 248, 8, 80, 20, this);
            this._commonEnterBtnLabel.mouseEnabled = false;
            this._bossEnterBtnLabel = ObjCreate.createGTextField("", 251, 35, 80, 20, this);
            this._bossEnterBtnLabel.mouseEnabled = false;
            this.serverTxt1 = ObjCreate.createGTextField("", 0, 5, 80, 20, this, GlobalStyle.textFormat1);
            this.serverTxt2 = ObjCreate.createGTextField("", 80, 5, 80, 20, this, GlobalStyle.textFormat2);
            this.serverTxt3 = ObjCreate.createGTextField("", 160, 5, 80, 20, this, GlobalStyle.textFormat5);
            this.bossTxt1 = ObjCreate.createGTextField("", 0, 35, 80, 20, this, GlobalStyle.textFormatRed);
            this.bossTxt2 = ObjCreate.createGTextField("", 80, 35, 80, 20, this, GlobalStyle.textFormatRed);
            this.bossTxt3 = ObjCreate.createGTextField("", 160, 35, 80, 20, this, GlobalStyle.textFormatRed);
            var loc1=ResouceConst.getScaleBitmap("SplitLine");
            ObjCreate.setObjAttri(loc1, 0, 58, 316, 2, this);
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            var loc1=null;
            var loc2=false;
            var loc3=false;
            super.data = arg1;
            if (typeof arg1 === "bossfieldorderdata") 
            {
                this._vo = arg1 as BossFieldOrderData;
                this.bossFieldInfo = (arg1 as BossFieldOrderData).bossFieldInfo;
                loc1 = ColorConfig.instance.getCampColor(this._vo.force).color;
                loc2 = GameConst.CrossBossFieldCampForceMaxPlayerNum - this.bossFieldInfo.playerNumMap[this._vo.force] <= 0;
                loc3 = 3 - this.bossFieldInfo.bossNumMap[this._vo.force] <= 0;
                this._commonEnterBtn.enabled = !loc2;
                this._bossEnterBtn.enabled = !loc3;
                this._commonEnterBtnLabel.filters = loc2 ? [FilterConst.colorFilter2] : [];
                this._bossEnterBtnLabel.filters = loc3 ? [FilterConst.colorFilter2] : [];
                this._commonEnterBtnLabel.htmlText = HTMLUtil.addColor(GameDefConfig.instance.getCrossBossFieldName(this._vo.force) + "(" + (GameConst.CrossBossFieldCampForceMaxPlayerNum - this.bossFieldInfo.playerNumMap[this._vo.force]) + ")", loc1);
                this._bossEnterBtnLabel.htmlText = HTMLUtil.addColor(Language.getStringByParam(28050, 3 - this.bossFieldInfo.bossNumMap[this._vo.force]), loc1);
                this._commonEnterBtn.invalidate();
                this._bossEnterBtn.invalidate();
                this._commonEnterBtn.drawNow();
                this._bossEnterBtn.drawNow();
                this.serverTxt1.text = GameDefConfig.instance.getCrossBossFieldName(1) + "（" + this.bossFieldInfo.playerNumMap[1] + "/" + GameConst.CrossBossFieldCampForceMaxPlayerNum + "）";
                this.serverTxt2.text = GameDefConfig.instance.getCrossBossFieldName(2) + "（" + this.bossFieldInfo.playerNumMap[2] + "/" + GameConst.CrossBossFieldCampForceMaxPlayerNum + "）";
                this.serverTxt3.text = GameDefConfig.instance.getCrossBossFieldName(3) + "（" + this.bossFieldInfo.playerNumMap[3] + "/" + GameConst.CrossBossFieldCampForceMaxPlayerNum + "）";
                this.bossTxt1.text = Language.getStringByParam(28050, this.bossFieldInfo.bossNumMap[1] + "/" + "3");
                this.bossTxt2.text = Language.getStringByParam(28050, this.bossFieldInfo.bossNumMap[2] + "/" + "3");
                this.bossTxt3.text = Language.getStringByParam(28050, this.bossFieldInfo.bossNumMap[3] + "/" + "3");
            }
            return;
        }

        /* internal  */onCommonEnterHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var e: Object /* flash.events.MouseEvent */;
            var callBack: Function;

            var loc1;
            callBack = null;
            e = arg1;
            callBack = (arg1: int): void
            {
                if (arg1 == Alert.OK) 
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.CrossBossFieldRequestComein, {"fieldId": bossFieldInfo.fieldId, "force": _vo.force}));
                }
                return;
            }
            if (this.bossFieldInfo) 
            {
                RoleAvatar.alertChangeMode(callBack);
            }
            return;
        }

        /* internal  */onBossEnterHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var e: Object /* flash.events.MouseEvent */;
            var monsterCallBack: Function;

            var loc1;
            monsterCallBack = null;
            e = arg1;
            monsterCallBack = (arg1: int): void
            {
                if (arg1 == Alert.OK) 
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.CrossBossFieldRequestComein, {"fieldId": bossFieldInfo.fieldId, "force": 0}));
                }
                return;
            }
            if (this.bossFieldInfo) 
            {
                RoleAvatar.alertChangeMode(monsterCallBack);
            }
            return;
        }

        /* internal */ /* var */serverTxt1: GTextFiled;

        /* internal */ /* var */serverTxt2: GTextFiled;

        /* internal */ /* var */serverTxt3: GTextFiled;

        /* internal */ /* var */bossTxt1: GTextFiled;

        /* internal */ /* var */bossTxt2: GTextFiled;

        /* internal */ /* var */bossTxt3: GTextFiled;

        /* internal */ /* var */_commonEnterBtn: GButton;

        /* internal */ /* var */_bossEnterBtn: GButton;

        /* internal */ /* var */_commonEnterBtnLabel: GTextFiled;

        /* internal */ /* var */_bossEnterBtnLabel: GTextFiled;

        /* internal */ /* var */bossFieldInfo: SBossFieldInfo;

        /* internal */ /* var */_vo: BossFieldOrderData;
    }
